package org.me.SendSMS;

import java.util.ArrayList;
import java.util.List;

import org.me.SendSMS.adapter.MessageAdapter;
import org.me.SendSMS.data.Message;
import org.me.SendSMS.utli.XMLUtli;

import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;
import com.google.android.apps.analytics.GoogleAnalyticsTracker;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;

public class MessageActivity extends Activity {
	
	ListView listMessage;
	Button btnBack;
	MessageAdapter adapter;
	Context mContext;
	List<Message> mListMessage = new ArrayList<Message>();
	LinearLayout llAdMode;
	private GoogleAnalyticsTracker tracker;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		 tracker = GoogleAnalyticsTracker.getInstance();
	     // Start the tracker in manual dispatch mode...
	    tracker.startNewSession("UA-35081259-1", getApplication());
		setContentView(R.layout.listview_message);
		mContext		= this;
		btnBack			= (Button) findViewById(R.id.btnCancelMessage);
		btnBack.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
			}
		});
		
		llAdMode = (LinearLayout)findViewById(R.id.llAdmob);
		

		try {
			AdView adView = new AdView(this, AdSize.BANNER, "a1503c30e415e29");
			  
		    // Add the adView to it
			llAdMode.addView(adView);
		     
		    // Initiate a generic request to load it with an ad
		    AdRequest request = new AdRequest();
		    request.setTesting(true);

		    adView.loadAd(request);  
		} catch (Exception e) {
			// TODO: handle exception
		}
		listMessage		= (ListView) findViewById(R.id.listMessage);
		mListMessage	= XMLUtli.parserXML(mContext);
		
		adapter			= new MessageAdapter(mContext, mListMessage);
		listMessage.setAdapter(adapter);
		
		
		
		
	}

}
